package io.github.wx.web;

import com.jfinal.aop.Duang;
import com.jfinal.kit.PropKit;
import com.jfinal.weixin.sdk.api.ApiConfig;
import com.jfinal.weixin.sdk.jfinal.ApiController;
import io.github.wx.common.easyui.DataGrid;
import io.github.wx.service.WeiXinApiService;

/**
 * Created by jie on 2017/4/3.
 * 获取微信API
 */
public class WeixinApiController extends ApiController {
    /**
     * 微信参数配置
     *
     * @return 配置对象
     */
    public ApiConfig getApiConfig() {
        ApiConfig ac = new ApiConfig();
        ac.setToken(PropKit.get("token"));
        ac.setAppId(PropKit.get("appId"));
        ac.setAppSecret(PropKit.get("appSecret"));
        ac.setEncryptMessage(PropKit.getBoolean("encryptMessage", false));
        ac.setEncodingAesKey(PropKit.get("encodingAesKey", "setting it in config file"));
        return ac;
    }

    public void getFollowsUser() {
        WeiXinApiService weiXinApiService = Duang.duang(WeiXinApiService.class);
        DataGrid dataGrid = weiXinApiService.getFollows();
        renderJson(dataGrid);
    }
}
